<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>阳光成单系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="./css/x-admin.css" media="all">
</head>

<body>
	<div class="x-body">
		<form class="layui-form" onsubmit="return false" id="form_editChanPingXiangQing">
			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品ID </label>
				<div class="layui-input-inline">
					<input type="text" id="chanPingId" name="chanPingId" required=""
						lay-verify="required" autocomplete="off" value="1" readonly=""
						class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> <span
					class="x-red"></span>产品名字
				</label>
				<div class="layui-input-inline">
					<input type="text" id="chanPinName" name="chanPinName"  autocomplete="off" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品地址
				</label>
				<div class="layui-input-inline">
					<input type="text" id="chanPinDiZhi" name="chanPinDiZhi" autocomplete="off" class="layui-input">
				</div>
			</div>


			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品售价
				</label>
				<div class="layui-input-inline">
					<input type="text" id="chanPinShouJia" name="chanPinShouJia"  autocomplete="off" class="layui-input">
				</div>
			</div>


			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品市场价
				</label>
				<div class="layui-input-inline">
					<input type="text" id="chanPinShiChangJia" name="chanPinShiChangJia" autocomplete="off" class="layui-input">
				</div>
			</div>



			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品品牌
				</label>
				<div class="layui-input-inline">
					<input type="text" id="chanPinPaiZi" name="chanPinPaiZi" autocomplete="off" class="layui-input">
				</div>
			</div>
				
				
				
			<div class="layui-form-item">
				<label class="layui-form-label">产品是否过期</label>
				<div class="layui-input-inline">
					<select id="shiFouGuoqi" name="shiFouGuoqi">
					<option value="">请选择</option>
						<option value="否">否</option>
						<option value="是">是</option>
					</select>
				</div>
			</div>
				
				
				
				
				<div class="layui-form-item">
				<label class="layui-form-label">产品是否限量</label>
				<div class="layui-input-inline">
					<select id="shiFouXianLiang" name="shiFouXianLiang">
					<option value="">请选择</option>
						<option value="否">否</option>
						<option value="是">是</option>
					</select>
				</div>
			</div>
			
			
			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品保质期
				</label>
				<div class="layui-input-inline">
					<input type="text" id="baoZhiQi" name="baoZhiQi" autocomplete="off" class="layui-input">
				</div>
			</div>


			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品加工坊
				</label>
				<div class="layui-input-inline">
					<input type="text" id="jiaGongFang" name="jiaGongFang" autocomplete="off" class="layui-input">
				</div>
			</div>




			


			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品口味
				</label>
				<div class="layui-input-inline">
					<input type="text" id="kouWei" name="kouWei" autocomplete="off" class="layui-input">
				</div>
			</div>



			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品生产商
				</label>
				<div class="layui-input-inline">
					<input type="text" id="shenChangShang" name="shenChangShang" autocomplete="off" class="layui-input">
				</div>
			</div>




			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品重量
				</label>
				<div class="layui-input-inline">
					<input type="text" id="zhongLiang" name="zhongLiang"autocomplete="off" class="layui-input">
				</div>
			</div>
			
			
			<div class="layui-form-item">
				<label for="cname" class="layui-form-label"> 产品图片
				</label>
				<div class="layui-input-inline">
				<input id="imgs" name="imgs"  />
					<img src="../" id="imgs1" name="imgs1" height="100px" width="100px"/>
					
				</div>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn" id="btn_editChanPinXiangQing">
					  <i class="layui-icon">&#xe67c;</i>选择图片
					</button>
				</div>
			</div>


			<div class="layui-form-item">
				<label for="L_email" class="layui-form-label"> 产品分类
				</label>
				<div class="layui-input-inline">

					<select name="fenleiId" id="fenleiId">
						<option value="">请选择分类</option>
					</select>
				</div>
				
			</div>
			



			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="save" onclick="editChanPinXiangQing()" >
					修改</button>
			</div>
		</form>
	</div>
	<script src="./lib/layui/layui.js" charset="utf-8">
		
	</script>
	<script src="./js/x-layui.js" charset="utf-8">
		
	</script>
	<script>
		var $ = null;
		var form = null;
		var layer = null;
		layui.use([ 'form', 'layer','upload' ], function() {
			$ = layui.jquery;
			form = layui.form;
			layer = layui.layer;
			$(function() {
				selChanPingFenLei();
				getChanPinXiangQingbyId();
			})
			
			
			
			
			  var upload = layui.upload;
			   
			  //执行实例
			  var uploadInst = upload.render({
			    elem: '#btn_editChanPinXiangQing' //绑定元素
			    ,url: '../adminchanpingxiangqing?reqName=upload' //上传接口
			    ,done: function(res){
			      //上传完毕回调
			      $("#imgs").val('images/'+res.remark);
			      $("#imgs1").attr('src','../images/'+res.remark);
			      layer.msg("修改成功",{
		    		  icon:1,
		    		  time:2000
		    	  })
		    	 
			    }
			    ,error: function(){
			      //请求异常回调
			       layer.msg("修改失败",{
		    		  icon:2,
		    		  time:2000
		    	  })
			    }
			  });
		});

		function selChanPingFenLei() {
			$.post("../adminchanpinfenlei?reqName=selChanPinFenLei", {},
					function(res) {
						for (var i = 0; i < res.length; i++) {
							$("#fenleiId").append(
									"<option value='"+res[i].chanPinId+"'>"
											+ res[i].leiMing + "</option>");
							form.render("select");

						}
					}, "json");
		}
		
		
		
		function getChanPinXiangQingbyId(){
			$.post("../adminchanpingxiangqing?reqName=getChanPinXiangQingbyId",{
				chanPingXiangQingId:sessionStorage.getItem("cpxqid")
			},function(res){
				$("#chanPingId").val(res.chanPingId);
				$("#chanPinName").val(res.chanPinName);
				$("#chanPinDiZhi").val(res.chanPinDiZhi);
				$("#chanPinShouJia").val(res.chanPinShouJia);
				$("#chanPinShiChangJia").val(res.chanPinShiChangJia);
				$("#chanPinPaiZi").val(res.chanPinPaiZi);
				$("#shiFouGuoqi").val(res.shiFouGuoqi);
				$("#shiFouXianLiang").val(res.shiFouXianLiang);
				$("#baoZhiQi").val(res.baoZhiQi);
				$("#jiaGongFang").val(res.jiaGongFang);
				$("#kouWei").val(res.kouWei);
				$("#shenChangShang").val(res.shenChangShang);
				$("#zhongLiang").val(res.zhongLiang);
				$("#fenleiId").val(res.fenleiId);
				$("#imgs").val(res.imgs);
				$("#imgs1").attr("src",res.imgs);
			},"json")
		}
		
		function editChanPinXiangQing(){
			$.post("../adminchanpingxiangqing?reqName=editChanPinXiangQing",$("#form_editChanPingXiangQing").serialize(),function(res){
				if(res.success){
					layer.msg(res.message);
					 var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);//关闭当前页
						parent. selChanPingXiangQingByPage();  
				}else{
					layer.msg(res.message);
				}
			},"json")
		}
	</script>

</body>

</html>